var Bmob = require('utils/bmob.js')
Bmob.initialize(
  "4b6aba3792e7f8699032d1b16815de1b", //applicationid
  "98829f8324c94a46279a01fc135a0d94", //restapi key
  "22099e3ab69720dfb20fe639e83de3ef" //masterkey
);
App({
  onLaunch: function () {
    var me = this;
    // 设备信息
    wx.getSystemInfo({
      success: function (res) {
        me.screenWidth = res.windowWidth;
        me.screenHeight = res.windowHeight;
        me.pixelRatio = res.pixelRatio;
      }
    });
    let sysParam = wx.getStorageSync("sysParam");
    if (!sysParam) {
        this.loadSysParam();
    }
  },
  onShow: function () {
    console.log('App Show')
  },
  onHide: function () {
    console.log('App Hide')
  },
  globalData: {
    hasLogin: false
  },
  sysParam: {},
  //加载系统参数
  loadSysParam: function () {
      var me = this;
      var SysParam = Bmob.Object.extend("SysParam");
      var query = new Bmob.Query(SysParam);
      query.select('code', 'value');
      query.find({
          success: function (results) {
              console.log(results, "results");
              for (var i = 0; i < results.length; i++) {
                  var code = results[i].get("code");
                  var value = results[i].get("value");
                  me.sysParam[code] = value;
              }
              wx.setStorageSync("sysParam", me.sysParam);
          },
          error: function (error) {
              console.log(error, "error");
          }
      });
  }
});